package org.ycx.doc.dao.auto;

import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.ycx.doc.dao.model.DocProjectVersion;
import org.ycx.doc.dao.model.DocProjectVersionExample;

public interface DocProjectVersionMapper {
    @SelectProvider(type=DocProjectVersionSqlProvider.class, method="countByExample")
    long countByExample(DocProjectVersionExample example);

    @DeleteProvider(type=DocProjectVersionSqlProvider.class, method="deleteByExample")
    int deleteByExample(DocProjectVersionExample example);

    @Delete({
        "delete from doc_project_version",
        "where VER_ID = #{verId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer verId);

    @Insert({
        "insert into doc_project_version (APP_ID, APP_VERSION, ",
        "VER_START, VER_END)",
        "values (#{appId,jdbcType=INTEGER}, #{appVersion,jdbcType=INTEGER}, ",
        "#{verStart,jdbcType=INTEGER}, #{verEnd,jdbcType=INTEGER})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="verId", before=false, resultType=Integer.class)
    int insert(DocProjectVersion record);

    @InsertProvider(type=DocProjectVersionSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="appId", before=false, resultType=Integer.class)
    int insertSelective(DocProjectVersion record);

    @SelectProvider(type=DocProjectVersionSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="VER_ID", property="verId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="APP_ID", property="appId", jdbcType=JdbcType.INTEGER),
        @Result(column="APP_VERSION", property="appVersion", jdbcType=JdbcType.INTEGER),
        @Result(column="VER_START", property="verStart", jdbcType=JdbcType.INTEGER),
        @Result(column="VER_END", property="verEnd", jdbcType=JdbcType.INTEGER)
    })
    List<DocProjectVersion> selectByExample(DocProjectVersionExample example);

    @Select({
        "select",
        "VER_ID, APP_ID, APP_VERSION, VER_START, VER_END",
        "from doc_project_version",
        "where VER_ID = #{verId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="VER_ID", property="verId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="APP_ID", property="appId", jdbcType=JdbcType.INTEGER),
        @Result(column="APP_VERSION", property="appVersion", jdbcType=JdbcType.INTEGER),
        @Result(column="VER_START", property="verStart", jdbcType=JdbcType.INTEGER),
        @Result(column="VER_END", property="verEnd", jdbcType=JdbcType.INTEGER)
    })
    DocProjectVersion selectByPrimaryKey(Integer verId);

    @UpdateProvider(type=DocProjectVersionSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") DocProjectVersion record, @Param("example") DocProjectVersionExample example);

    @UpdateProvider(type=DocProjectVersionSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") DocProjectVersion record, @Param("example") DocProjectVersionExample example);

    @UpdateProvider(type=DocProjectVersionSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(DocProjectVersion record);

    @Update({
        "update doc_project_version",
        "set APP_ID = #{appId,jdbcType=INTEGER},",
          "APP_VERSION = #{appVersion,jdbcType=INTEGER},",
          "VER_START = #{verStart,jdbcType=INTEGER},",
          "VER_END = #{verEnd,jdbcType=INTEGER}",
        "where VER_ID = #{verId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(DocProjectVersion record);
}